import jiagu


def get_loc_name(text):
    if text is None:
        return ''
    if len(text) == 0:
        return ''
    jiagu.init()  # 可手动初始化，也可以动态初始化
    words = jiagu.seg(text) # 分词
    print(words)
    # pos = jiagu.pos(words) # 词性标注
    # print(pos)
    ner = jiagu.ner(words) # 命名实体识别
    print(ner)
    # list = []
    for index in range(len(ner)):
        if ner[index] == 'B-LOC' or ner[index] == 'I-LOC':
            return words[index]
            # list.append(index)
    return ''
    # loc = ''
    # if list.__len__() > 0:
    #     for index in range(len(list)):
    #         loc = loc + words[list[index]]
    # return loc